*****************************************************************
*GENERATES TABLES IN MAIN PAPER: HOW POLITICAL INSIDERS LOSE OUT*
*****************************************************************

log using final_table_log_file.log, replace

cd "Replication Data"


*TABLE 2: HH SURVEY RESULTS ON POLIITCAL PARTICIPATION*

use finalusingindices_withbaselinepol_anon.dta, clear

*RECODING MISSING BASELINE DATA AS 0 FOR INDICES

foreach i in villageparticipation villagequality DAquality food_security literacy_education health_nutrition environment livelihood{
			replace `i'_index0 = 0 if `i'_miss == 1
}


reg villageparticipation_index1  treatment villageparticipation_index0 villageparticipation_miss i.distnum, cluster(cluster2)
ivregress gmm villageparticipation_index1 (received=treatment) villageparticipation_index0 villageparticipation_miss i.distnum, vce(cluster cluster2)
sum villageparticipation_index1 if treatment==0 

reg villageparticipation_index1 treatment villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm villageparticipation_index1 (received=treatment) villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum villageparticipation_index1 if treatment==0 & NDC_HH_base==1

reg villageparticipation_index1 treatment villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm villageparticipation_index1 (received=treatment) villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum villageparticipation_index1 if treatment==0 & NDC_HH_base==0


reg villagequality_index1 treatment villagequality_index0 villagequality_miss i.distnum, cluster(cluster2)
ivregress gmm villagequality_index1 (received=treatment) villagequality_index0 villagequality_miss i.distnum, vce(cluster cluster2)
sum villagequality_index1 if treatment==0 

reg villagequality_index1 treatment villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm  villagequality_index1 (received=treatment) villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum villagequality_index1 if treatment==0 & NDC_HH_base==1

reg villagequality_index1 treatment villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm villagequality_index1 (received=treatment) villageparticipation_index0 villageparticipation_miss i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum villagequality_index1 if treatment==0 & NDC_HH_base==0


reg DAquality_index1 treatment DAquality_index0 DAquality_miss i.distnum, cluster(cluster2)
ivregress gmm DAquality_index1 (received=treatment) DAquality_index0 DAquality_miss i.distnum, vce(cluster cluster2)
sum DAquality_index1 if treatment==0 

reg DAquality_index1 treatment DAquality_index0 DAquality_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm  DAquality_index1 (received=treatment) DAquality_index0 DAquality_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum DAquality_index1 if treatment==0 & NDC_HH_base==1

reg DAquality_index1 treatment DAquality_index0 DAquality_miss i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm DAquality_index1 (received=treatment) DAquality_index0 DAquality_miss i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum DAquality_index1 if treatment==0 & NDC_HH_base==0


*TABLE 3: LOCAL GOVERNMENT PARTICIPATION*

use electoralareadata_survey2006admin2010admin_polEA_anon, clear

xi: reg turnout EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm turnout (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum turnout if EAtreatment==0

xi: reg turnout EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm turnout (mobilizedEA=EAtreatment) i.district if eaNDC>=.3  & eaNDC<., vce(cluster supercluster2)
sum turnout if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg turnout EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm turnout (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum turnout if EAtreatment==0 & eaNDC<.3


xi: reg numcandidatesBEST EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm numcandidatesBEST (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum numcandidatesBEST if EAtreatment==0

xi: reg numcandidatesBEST EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm numcandidatesBEST (mobilizedEA=EAtreatment) i.district if eaNDC>=.3 & eaNDC<., vce(cluster supercluster2)
sum numcandidatesBEST if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg numcandidatesBEST EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm numcandidatesBEST (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum numcandidatesBEST if EAtreatment==0 & eaNDC<.3


xi: reg st_activity EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm st_activity (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum st_activity if EAtreatment==0

xi: reg st_activity EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm st_activity (mobilizedEA=EAtreatment) i.district if eaNDC>=.3 & eaNDC<., vce(cluster supercluster2)
sum st_activity if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg st_activity EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm st_activity (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum st_activity if EAtreatment==0 & eaNDC<.3

*TABLE 4*

*PANEL A*

use finalusingindices_withbaselinepol_anon.dta, clear

reg timemoneyPG1 treatment  i.distnum, cluster(cluster2)
ivregress gmm timemoneyPG1 (received=treatment)  i.distnum, vce(cluster cluster2)
sum timemoneyPG1 if treatment==0

reg timemoneyPG1 treatment  i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm timemoneyPG1 (received=treatment)  i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum timemoneyPG1 if treatment==0 & NDC_HH_base==1

reg timemoneyPG1 treatment  i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm timemoneyPG1 (received=treatment)  i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum timemoneyPG1 if treatment==0 & NDC_HH_base==0

reg timemoneyPGEpi1 treatment i.distnum, cluster(cluster2)
ivregress gmm timemoneyPGEpi1 (received=treatment) i.distnum, vce(cluster cluster2)
sum timemoneyPGEpi1 if treatment==0 

reg timemoneyPGEpi1 treatment i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm timemoneyPGEpi1 (received=treatment) i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum timemoneyPGEpi1 if treatment==0 & NDC_HH_base==1

reg timemoneyPGEpi1 treatment i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm timemoneyPGEpi1 (received=treatment) i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum timemoneyPGEpi1 if treatment==0 & NDC_HH_base==0


reg timemoneyPGNotEpi1 treatment i.distnum, cluster(cluster2)
ivregress gmm timemoneyPGNotEpi1 (received=treatment) i.distnum, vce(cluster cluster2)
sum timemoneyPGNotEpi1 if treatment==0

reg timemoneyPGNotEpi1 treatment i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm timemoneyPGNotEpi1 (received=treatment) i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum timemoneyPGNotEpi1 if treatment==0 & NDC_HH_base==1

reg timemoneyPGNotEpi1 treatment i.distnum if NDC_HH_base==0, cluster(cluster2)
ivregress gmm timemoneyPGNotEpi1 (received=treatment) i.distnum if NDC_HH_base==0, vce(cluster cluster2)
sum timemoneyPGNotEpi1 if treatment==0 & NDC_HH_base==0


use electoralareadata_survey2006admin2010admin_polEA_anon, clear

*PANEL B*

xi: reg avLGfinancing EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm avLGfinancing (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum avLGfinancing if EAtreatment==0

xi: reg avLGfinancing EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm avLGfinancing (mobilizedEA=EAtreatment) i.district if eaNDC>=.3 & eaNDC<., vce(cluster supercluster2)
sum avLGfinancing if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg avLGfinancing EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm avLGfinancing (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum avLGfinancing if EAtreatment==0 & eaNDC<.3


xi: reg avLGfinancing_epi EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm avLGfinancing_epi (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum avLGfinancing_epi if EAtreatment==0

xi: reg avLGfinancing_epi EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm avLGfinancing_epi (mobilizedEA=EAtreatment) i.district if eaNDC>=.3 & eaNDC<., vce(cluster supercluster2)
sum avLGfinancing_epi if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg avLGfinancing_epi EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm avLGfinancing_epi (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum avLGfinancing_epi if EAtreatment==0 & eaNDC<.3


xi: reg avLGfinancing_notepi EAtreatment i.district, cluster(supercluster2)
xi: ivregress gmm avLGfinancing_notepi (mobilizedEA=EAtreatment) i.district, vce(cluster supercluster2)
sum avLGfinancing_notepi if EAtreatment==0

xi: reg avLGfinancing_notepi EAtreatment i.district if eaNDC>=.3 & eaNDC<., cluster(supercluster2)
xi: ivregress gmm avLGfinancing_notepi (mobilizedEA=EAtreatment) i.district if eaNDC>=.3 & eaNDC<., vce(cluster supercluster2)
sum avLGfinancing_notepi if EAtreatment==0 & eaNDC>=.3 & eaNDC<.

xi: reg avLGfinancing_notepi EAtreatment i.district if eaNDC<.3, cluster(supercluster2)
xi: ivregress gmm avLGfinancing_notepi (mobilizedEA=EAtreatment) i.district if eaNDC<.3, vce(cluster supercluster2)
sum avLGfinancing_notepi if EAtreatment==0 & eaNDC<.3


*TABLE 5*

use finalusingindices_withbaselinepol_anon.dta, clear

*RECODING MISSING BASELINE DATA AS 0 FOR INDICES

foreach i in food_security literacy_education health_nutrition environment livelihood wellbeing{
			replace `i'_index0 = 0 if `i'_miss == 1
}


reg wellbeing_index1 treatment wellbeing_index0 wellbeing_miss i.distnum, cluster(cluster2)
ivregress gmm wellbeing_index1 (received=treatment) wellbeing_index0 wellbeing_miss i.distnum, vce(cluster cluster2)
sum wellbeing_index1 if treatment==0

reg wellbeing_index1 treatment wellbeing_index0 wellbeing_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm wellbeing_index1 (received=treatment) wellbeing_index0 wellbeing_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum wellbeing_index1 if treatment==0 & NDC_HH_base==1

reg wellbeing_index1 treatment wellbeing_index0 wellbeing_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm wellbeing_index1 (received=treatment) wellbeing_index0 wellbeing_miss  i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum wellbeing_index1 if treatment==0 & (NDC_HH_base==0)

****

reg food_security_index1 treatment food_security_index0 food_security_miss i.distnum, cluster(cluster2)
ivregress gmm food_security_index1 (received=treatment) food_security_index0 food_security_miss i.distnum, vce(cluster cluster2)
sum food_security_index1 if treatment==0 


reg food_security_index1 treatment food_security_index0 food_security_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm food_security_index1 (received=treatment) food_security_index0 food_security_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum food_security_index1 if treatment==0 & NDC_HH_base==1

reg food_security_index1 treatment food_security_index0 food_security_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm food_security_index1 (received=treatment) food_security_index0 food_security_miss i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum food_security_index1 if treatment==0 & (NDC_HH_base==0)



****

reg literacy_education_index1 treatment literacy_education_index0 literacy_education_miss i.distnum, cluster(cluster2)
ivregress gmm literacy_education_index1 (received=treatment) literacy_education_index0 literacy_education_miss i.distnum, vce(cluster cluster2)
sum literacy_education_index1 if treatment==0 

reg literacy_education_index1 treatment literacy_education_index0 literacy_education_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm literacy_education_index1 (received=treatment) literacy_education_index0 literacy_education_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum literacy_education_index1 if treatment==0 & NDC_HH_base==1

reg literacy_education_index1 treatment literacy_education_index0 literacy_education_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm literacy_education_index1 (received=treatment) literacy_education_index0 literacy_education_miss i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum literacy_education_index1 if treatment==0 & (NDC_HH_base==0)


****

reg health_nutrition_index1 treatment health_nutrition_index0 health_nutrition_miss i.distnum, cluster(cluster2)
ivregress gmm health_nutrition_index1 (received=treatment) health_nutrition_index0 health_nutrition_miss i.distnum, vce(cluster cluster2)
sum health_nutrition_index1 if treatment==0 

reg health_nutrition_index1 treatment health_nutrition_index0 health_nutrition_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm health_nutrition_index1 (received=treatment) health_nutrition_index0 health_nutrition_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum health_nutrition_index1 if treatment==0 & NDC_HH_base==1

reg health_nutrition_index1 treatment health_nutrition_index0 health_nutrition_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm health_nutrition_index1 (received=treatment) health_nutrition_index0 health_nutrition_miss i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum health_nutrition_index1 if treatment==0 & (NDC_HH_base==0)

****

reg environment_index1 treatment environment_index0 environment_miss i.distnum, cluster(cluster2)
ivregress gmm environment_index1 (received=treatment) environment_index0 environment_miss i.distnum, vce(cluster cluster2)
sum environment_index1 if treatment==0 

reg environment_index1 treatment environment_index0 environment_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm environment_index1 (received=treatment) environment_index0 environment_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum environment_index1 if treatment==0 & NDC_HH_base==1

reg environment_index1 treatment environment_index0 environment_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm environment_index1 (received=treatment) environment_index0 environment_miss i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum environment_index1 if treatment==0 & (NDC_HH_base==0)

****

reg livelihood_index1 treatment livelihood_index0 livelihood_miss i.distnum, cluster(cluster2)
ivregress gmm livelihood_index1 (received=treatment) livelihood_index0 livelihood_miss i.distnum, vce(cluster cluster2)
sum livelihood_index1 if treatment==0 

reg livelihood_index1 treatment livelihood_index0 livelihood_miss i.distnum if NDC_HH_base==1, cluster(cluster2)
ivregress gmm livelihood_index1 (received=treatment) livelihood_index0 livelihood_miss i.distnum if NDC_HH_base==1, vce(cluster cluster2)
sum livelihood_index1 if treatment==0 & NDC_HH_base==1

reg livelihood_index1 treatment livelihood_index0 livelihood_miss i.distnum if (NDC_HH_base==0), cluster(cluster2)
ivregress gmm livelihood_index1 (received=treatment) livelihood_index0 livelihood_miss i.distnum if (NDC_HH_base==0), vce(cluster cluster2)
sum livelihood_index1 if treatment==0 & (NDC_HH_base==0)



log close

